home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97b.txt / 000127_icon-group-sender _Mon Dec 1 09:24:39 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
  3.     by baskerville.CS.Arizona.EDU (8.8.7/8.8.7) with SMTP id JAA06519
  4.     for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Mon, 1 Dec 1997 09:24:38 -0700 (MST)
  5. Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
  6.     id AA00709; Mon, 1 Dec 1997 09:24:37 -0700
  7. Message-Id: <347B8113.C76C7986@ix.netcom.com>
  8. Date: Tue, 25 Nov 1997 20:53:23 -0500
  9. From: Phillip Lee Thomas <teruthom@ix.netcom.com>
  10. Reply-To: thomaspl@acm.org
  11. X-Mailer: Mozilla 4.03 [en] (Win95; U)
  12. Mime-Version: 1.0
  13. To: Mike D Cross <crossmd@mh.uk.sbphrd.com>
  14. Cc: icon-group@optima.CS.Arizona.EDU
  15. Subject: Re: Question - How to extract data from a formatted line.
  16. References: <199711221443.OAA03592@heu534.ha.uk.sbphrd.com>
  17. Content-Type: text/plain; charset=us-ascii
  18. Content-Transfer-Encoding: 7bit
  19. Errors-To: icon-group-errors@optima.CS.Arizona.EDU
  20. Status: RO
  21.  
  22. Mike,
  23.   I'm not literate in Perl -- your own example might be a fair reason of why I've
  24. avoided
  25. such literacy.
  26.  
  27. Here's a truncated program that 1) sets up a list, 2) identifies a field
  28. terminator character
  29. sequence, 3) pulls out the strings upto the terminators, 4) places them in a
  30. list, and 5) prints them out.
  31.  
  32. In any real situation, you would read in the data ("while line := read() do
  33. ..."), and determine
  34. whether you need to store the parsed elements for further processing, launder
  35. them further, etc.
  36.  
  37. In the present example, if your string is not terminated by the field terminator,
  38. then you
  39. need one further put(mylist, tab(0)) after the while loop.
  40.  
  41. -- Phillip Thomas
  42.  
  43.  
  44. procedure main()
  45.    mylist := []
  46.    terminator := "xxx"
  47.  
  48.    line := "this isxxxa linexxxof formatted dataxxx"
  49.  
  50.    line ?  {
  51.       while put(mylist, tab(find(terminator))) do   # grab the data
  52.          move(*terminator)                                  # skip length of
  53. terminator
  54.       }
  55.    while write(pop(mylist))
  56. end
  57.  
  58. Mike D Cross wrote:
  59.  
  60. > Hi,
  61. >
  62. > I've been given some Perl programs which extract data from lines
  63. > of text, each line being of a set format. In perl you do:
  64. >
  65. > @dumpline = /^RLOGNAME=\"(.*)\" UID=\"(.*)\" GID=\"(.*)\" PROFILE=\"(.*)\"
  66.  
  67.  
  68.  
  69.